set -ex

rm -rf ./build
mkdir build
cd build

# export CUDA_VISIBLE_DEVICES=2
# ARCH=75
# export CUDA_VISIBLE_DEVICES=1
# ARCH=86
# export CUDA_VISIBLE_DEVICES=0
# ARCH=89
# export CUDA_VISIBLE_DEVICES=1
# ARCH=75
# export CUDA_VISIBLE_DEVICES=0
# ARCH=61
export CUDA_VISIBLE_DEVICES=7
ARCH=75

eval=0
perf=1
profile=0

if [ $eval -eq 1 ]; then
    cmake ../ -DARCH=$ARCH -DMODE="EVAL"
    make -j32
    python3 ../run_case.py ../../eval_gt/test_case.txt
fi
if [ $perf -eq 1 ]; then
    cmake ../ -DARCH=$ARCH -DMODE="PERF"
    # cmd="nsys profile --gpu-metrics-device=0 ./reduce"
    cmd="./reduce"
    make -j32
    $cmd
fi
if [ $profile -eq 1 ]; then
    cmake ../ -DARCH=$ARCH -DMODE="PROFILE"
    cmd="ncu --set full -k reduce_sm75 --target-processes all ./reduce"
    make -j32
    $cmd
fi

# python3 eval_script/eval_speedup.py \
# eval_release/rel2/speedup_m_10_700_w_sm75.log:eval_release/rel0/speedup_m_10_700_w_sm75.log \
# sm75 eval_release/rel2/speedup_m_10_700_w_sm75.jpg